#include "utility.h"

#define ENABLE_LOG

char Log::filename[100];
ofstream Log::fs;

void Log::init(const char* _filename) {
	strcpy(filename, _filename);
	fs.open(filename, ios::out);
	log("Log::init(), filename=%s\n", filename);
}

void Log::close() {
	log("Log::close() called\n");
	fs.close();
}

void Log::log(const char* text, ...) {
#ifdef ENABLE_LOG

	char buffer[MAX_CHAR];

	va_list ap;
	va_start(ap, text);
	vsprintf(buffer, text, ap);
	va_end(ap);

	fs << buffer;
	fs.flush();

#endif
}

void Log::slog(const char* text, ...) {
	char buffer[MAX_CHAR];

	va_list ap;
	va_start(ap, text);
	vsprintf(buffer, text, ap);
	va_end(ap);

	fs << buffer;
	fs.flush();
}
